# 带自编译的Dockerfile
# alpine的源配置的是ustc.可以更换的.

# 如果多次在同一台服务器构建,注意构建命令,不要使用缓存.
# docker build --no-cache -t test .

# complie
FROM golang:1.21-alpine AS gobuilder
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
        && apk add git \
        && go env -w GOPROXY=https://goproxy.cn,direct \
        && go env -w GO111MODULE="auto" \
        && git clone https://gitee.com/cynen/wxapp.git \
        && cd wxapp/server \
        && CGO_ENABLED=0 go build -o wxapp

# build images

FROM alpine:3.20
ENV LANG C.UTF-8
ENV TZ=Asia/Shanghai
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
    && apk update && apk upgrade \
    && apk add ca-certificates\
    && update-ca-certificates \
    && apk --no-cache add openssl wget bash tzdata curl \
    && set -ex
# 从上一个镜像中copy到当前容器里.
COPY --from=gobuilder /go/wxapp/server/wxapp /usr/bin/
EXPOSE 9090

ENTRYPOINT ["wxapp"]


# 启动应用
# docker run -d --name webhook  -p 63900:8888 cynen:demo
#